using System.Transactions;

namespace EmailGateway
{
    public class CodeThatYouUsuallySeeInProjects
    {
private IRepository repository;
private IEmailGateway emailGateway;

public void CreateUser(string userName,string password)
{
    using(var transaction = new TransactionScope())
    {
        var user = new User
                       {
                           UserName = userName, 
                           Password = password
                       };

        repository.Save(user);

        emailGateway.SendEmail(userName,
                               "Account created",
                               "Please click the following link to activate account: " +
                               "http://mysite/confirm&id=" + user.Id);

        
        transaction.Complete();
    }
}
}
}